<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('考勤详情列表')" />
</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="attendId" name="attendId" th:value="${attend.attendId}">
                    <input type="hidden" id="userId" name="userId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>考勤时间：</label>
                                <input type="text" class="time-input" th:value="${attend.attendMonth}" disabled data-type="month" name="attendMonth"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group" th:if="${attend.attendStatus == '0'}">
                <a class="btn btn-success" onclick="add()">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-table-print-js" />
    <script th:inline="javascript">
        var datas = [[${@dict.getType('attend_status')}]];
        var prefix = ctx + "record/attend/content";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showPrint: true,
                printPageBuilder: printPageBuilder,
                modalName: "考勤详情",
                columns: [{
                    checkbox: true,
                    printIgnore: true
                },
                {
                    field: 'contentId',
                    title: '详情id',
                    visible: false,
                    printIgnore: true
                },
                {
                    field: 'userName',
                    title: '员工',
                    sortable: true
                },
                {
                    field: 'day1',
                    title: '1',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day2',
                    title: '2',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day3',
                    title: '3',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day4',
                    title: '4',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day5',
                    title: '5',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day6',
                    title: '6',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day7',
                    title: '7',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day8',
                    title: '8',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day9',
                    title: '9',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day10',
                    title: '10',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day11',
                    title: '11',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day12',
                    title: '12',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day13',
                    title: '13',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day14',
                    title: '14',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day15',
                    title: '15',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day16',
                    title: '16',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day17',
                    title: '17',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day18',
                    title: '18',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day19',
                    title: '19',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day20',
                    title: '20',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day21',
                    title: '21',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day22',
                    title: '22',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day23',
                    title: '23',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day24',
                    title: '24',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day25',
                    title: '25',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day26',
                    title: '26',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day27',
                    title: '27',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day28',
                    title: '28',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day29',
                    title: '29',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day30',
                    title: '30',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'day31',
                    title: '31',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    title: '出勤',
                    formatter: function(value, row, index) {
                        return countVac(row, '01');
                    }
                },
                {
                    title: '休息',
                    formatter: function(value, row, index) {
                        return countVac(row, '02');
                    }
                },
                {
                    title: '病假',
                    formatter: function(value, row, index) {
                        return countVac(row, '03');
                    }
                },
                {
                    title: '事假',
                    formatter: function(value, row, index) {
                        return countVac(row, '04');
                    }
                },
                {
                    title: '工伤',
                    formatter: function(value, row, index) {
                        return countVac(row, '05');
                    }
                },
                {
                    title: '婚丧假',
                    formatter: function(value, row, index) {
                        return countVac(row, '06');
                    }
                },
                {
                    title: '探亲假',
                    formatter: function(value, row, index) {
                        return countVac(row, '07');
                    }
                },
                {
                    title: '调休',
                    formatter: function(value, row, index) {
                        return countVac(row, '08');
                    }
                },
                {
                    title: '旷工',
                    formatter: function(value, row, index) {
                        return countVac(row, '09');
                    }
                },
                {
                    title: '加班',
                    formatter: function(value, row, index) {
                        return countVac(row, '10');
                    }
                },
                {
                    title: '工休假',
                    formatter: function(value, row, index) {
                        return countVac(row, '12');
                    }
                },
                {
                    title: '产假',
                    formatter: function(value, row, index) {
                        return countVac(row, '13');
                    }
                },
                {
                    title: '其他',
                    formatter: function(value, row, index) {
                        return countVac(row, '11');
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                }]
            };
            $.table.init(options);
        });

        function countVac(row, value) {
            var count = 0;
            if(row.day1 == value){
                count ++;
            }
            if(row.day2 == value){
                count ++;
            }
            if(row.day3 == value){
                count ++;
            }
            if(row.day4 == value){
                count ++;
            }
            if(row.day5 == value){
                count ++;
            }
            if(row.day6 == value){
                count ++;
            }
            if(row.day7 == value){
                count ++;
            }
            if(row.day8 == value){
                count ++;
            }
            if(row.day9 == value){
                count ++;
            }
            if(row.day10 == value){
                count ++;
            }
            if(row.day11 == value){
                count ++;
            }
            if(row.day12 == value){
                count ++;
            }
            if(row.day13 == value){
                count ++;
            }
            if(row.day14 == value){
                count ++;
            }
            if(row.day15 == value){
                count ++;
            }
            if(row.day16 == value){
                count ++;
            }
            if(row.day17 == value){
                count ++;
            }
            if(row.day18 == value){
                count ++;
            }
            if(row.day19 == value){
                count ++;
            }
            if(row.day20 == value){
                count ++;
            }
            if(row.day21 == value){
                count ++;
            }
            if(row.day22 == value){
                count ++;
            }
            if(row.day23 == value){
                count ++;
            }
            if(row.day24 == value){
                count ++;
            }
            if(row.day25 == value){
                count ++;
            }
            if(row.day26 == value){
                count ++;
            }
            if(row.day27 == value){
                count ++;
            }
            if(row.day28 == value){
                count ++;
            }
            if(row.day29 == value){
                count ++;
            }
            if(row.day30 == value){
                count ++;
            }
            if(row.day31 == value){
                count ++;
            }
            return count;
        }

        function add(){
            var attendId = $("#attendId").val();
            $.operate.add(attendId);
        }

        // 自定义打印页面模板
        function printPageBuilder(table) {
            return `
        	<html>
        	  <head>
        	  <style type="text/css" media="print">
        	  @page {
        	    size: auto;
        	    margin: 25px 0 25px 0;
        	  }
        	  </style>
        	  <style type="text/css" media="all">
        	  table {
        	    border-collapse: collapse;
        	    font-size: 12px;
        	  }
        	  table, th, td {
        	    border: 1px solid grey;
        	  }
        	  th, td {
        	    text-align: center;
        	    vertical-align: middle;
        	  }
        	  p {
        	    font-weight: bold;
        	    margin-left:20px;
        	  }
        	  table {
        	    width:94%;
        	    margin-left:3%;
        	    margin-right:3%;
        	  }
        	  div.bs-table-print {
        	    text-align:center;
        	    margin-bottom: 20px;
        	  }
        	  </style>
        	  </head>
        	  <title>科室考勤记录</title>
        	  <body>
        	  <div class="bs-table-print">科室考勤记录</div>
        	  <div class="bs-table-print">考勤科室：[[${attend.deptName}]]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考勤日期：[[${attend.attendMonth}]]</div>
        	  <div class="bs-table-print">${table}</div>
        	  <div class="bs-table-print">考勤人：[[${attend.attendUser}]]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;科室负责人：[[${attend.deptUser}]]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
        	  <div class="bs-table-print">
        	        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> <font color="red">考勤标记：出勤划“√”，正常休息划“/”，工休假划“*”，病假划“！”，事假划“@”，工伤划“#”，婚丧假划“$”，探亲假划“%”，调休划“^”，旷工划“X”，加班划“+”，产假划“&”。如某段时间为外派或借调他科室，期间考勤空缺由相应科室进行考勤，其他情况划“-”，并用文字说明。</font></span>
              </div>
        	  </body>
        	</html>`
        }
    </script>
</body>
</html>